/**
 *
 */
$(document).ready(function() {
    $("#salveazaSecretara").click(function(e) {

        var postData = $("#adaugaSecretaraForm").serializeArray();
        var formURL = $("#adaugaSecretaraForm").attr("action");
        $.ajax({
            url : formURL,
            data : postData,
            type : "POST",
            success : function(data, textStatus, jqXHR) {
                //data: return data from server
                console.log("received data:" + data);
                switch(data) {
                    case 'fail':
                        alert("Aceasta adresa de email este daja folosita");
                        break;
                    case 'succes':
                        alert("Contul a fost creat cu succes");
                        $('input[type="text"]').val('');
                        $('input[type="email"]').val('');
                        break;
                    default:
                        break;
                }
            },
            error : function(jqXHR, textStatus, errorThrown) {
                //if fails
            }
        });

    });

   // $("#adaugaScretaraForm").submit();
    //Submit  the FORM
});
